package com.xingfudazi.app.util;

import java.util.*;

public class NFtoGMapping {

    // A map to store the mapping from (N, F) pairs to G values.
    private static final Map<String, List<String>> mapping = new HashMap<>();

    // Initialize the mapping based on provided rules.
    static {
        initializeMapping();
    }

    public static void main(String[] args) {
        // Test cases or user input can be used here to query the mapping.
        // Example usage:
        String n = "sun_01"; // Replace with desired N value.
        String f = "moon_02"; // Replace with desired F value.
        System.out.println("For " + n + " and " + f + ", the corresponding G values are: " + getGValues(n, f));

        // You can test other combinations by changing the above n and f values or by adding more print statements.
    }

    private static void initializeMapping() {
        addEntry("sun_01", "moon_01", "G2,G4,G6");
        addEntry("sun_01", "moon_02", "G2,G4,G6");
        addEntry("sun_01", "moon_03", "G4,G6");
        addEntry("sun_01", "moon_04", "G2,G3,G4,G5");
        addEntry("sun_01", "moon_05", "G1,G2,G3,G4,G5,G6");
        addEntry("sun_01", "moon_06", "G2,G4,G5");
        addEntry("sun_01", "moon_07", "G2,G4,G5");

        addEntry("sun_02", "moon_01", "G2,G4,G6");
        addEntry("sun_02", "moon_02", "G2,G4,G6");
        addEntry("sun_02", "moon_03", "G2,G3,G4,G5,G6");
        addEntry("sun_02", "moon_04", "G2,G3,G4,G5");
        addEntry("sun_02", "moon_05", "G1,G2,G3,G4,G5,G6");
        addEntry("sun_02", "moon_06", "G2,G4,G5");
        addEntry("sun_02", "moon_07", "G2,G4,G5");

        addEntry("sun_03", "moon_01", "G2,G3,G4,G5,G6");
        addEntry("sun_03", "moon_02", "G2,G3,G4,G5,G6");
        addEntry("sun_03", "moon_03", "G2,G4,G5");
        addEntry("sun_03", "moon_04", "G2,G3,G4,G5");
        addEntry("sun_03", "moon_05", "G1,G2,G3,G4,G5,G6");
        addEntry("sun_03", "moon_06", "G2,G4,G5");
        addEntry("sun_03", "moon_07", "G2,G4,G5");

        addEntry("sun_04", "moon_01", "G1,G2,G3,G5");
        addEntry("sun_04", "moon_02", "G2,G3,G5");
        addEntry("sun_04", "moon_03", "G2,G3,G5");
        addEntry("sun_04", "moon_04", "无");
        addEntry("sun_04", "moon_05", "G2,G3,G4,G5");
        addEntry("sun_04", "moon_06", "无");
        addEntry("sun_04", "moon_07", "无");

        addEntry("sun_05", "moon_01", "G1,G2,G3,G4,G5,G6");
        addEntry("sun_05", "moon_02", "G1,G2,G3,G4,G5,G6");
        addEntry("sun_05", "moon_03", "G1,G2,G3,G4,G5,G6");
        addEntry("sun_05", "moon_04", "G1,G2,G3,G4,G5");
        addEntry("sun_05", "moon_05", "G1,G2,G3,G4,G5,G6");
        addEntry("sun_05", "moon_06", "G1,G2,G3,G4,G5");
        addEntry("sun_05", "moon_07", "G1,G2,G3,G4,G5");

        addEntry("sun_06", "moon_01", "G2,G4,G5");
        addEntry("sun_06", "moon_02", "G2,G4,G5");
        addEntry("sun_06", "moon_03", "G2,G4,G5");
        addEntry("sun_06", "moon_04", "无");
        addEntry("sun_06", "moon_05", "G2,G3,G4,G5");
        addEntry("sun_06", "moon_06", "无");
        addEntry("sun_06", "moon_07", "无");

        addEntry("sun_07", "moon_01", "G2,G4,G5");
        addEntry("sun_07", "moon_02", "G2,G4,G5");
        addEntry("sun_07", "moon_03", "G2,G4,G5");
        addEntry("sun_07", "moon_04", "无");
        addEntry("sun_07", "moon_05", "G3");
        addEntry("sun_07", "moon_06", "无");
        addEntry("sun_07", "moon_07", "无");
    }

    private static void addEntry(String n, String f, String gValues) {
        if (gValues.equals("无")) {
            mapping.put(n + f, Collections.emptyList());
        } else {
            mapping.put(n + f, Arrays.asList(gValues.split(",")));
        }
    }

    public static List<String> getGValues(String n, String f) {
        return mapping.getOrDefault(n + f, Collections.emptyList());
    }
}
